{% extends "base.html" %}
{% block body %}

<div style="resize: vertical;margin-top:5px" class="card border-0 shadow" id="feed">
    <div class="card-header bg-header border border-dark shadow text-white">
        <h2 style="display:inline-block"><span class="operator">Live</span> Task Feed</h2>
        <span style="display:inline-block; float:right">
            <span class="input-group" >
                <div class="input-group-append"><input class="form-control" style="color:white" type="text" size="50rem" placeholder="filter with 'column title:value'" id="filter" v-model="filter"></div>
                <div class="input-group-append input-group-btn" ><button disabled type="button" class="btn btn{{config['outline-buttons']}}secondary"><i class="fa fa-filter"></i></button></div>
            </span>
        </span>
    </div>
    <div style="overflow-y:auto;height:calc(85vh);padding:0;" class="card-body bg-card-body border border-dark shadow" >
        <table v-if="Object.keys(tasks).length > 0" class="table table-condensed table-striped {{config['table-color']}}" style="word-wrap: break-word;table-layout: fixed">
            <tr style="padding:0">
                <th class="sticky-top" style="width:12rem">Time</th>
                <th class="sticky-top">Status</th>
                <th class="sticky-top" style="width:10rem">Operator</th>
                <th class="sticky-top" style="width:20rem">Context</th>
                <th class="sticky-top" style="width:4rem;text-align:left">Task</th>
                <th class="sticky-top" style="text-align:left">Command</th>
                <th class="sticky-top" style="width:10rem">Comment</th>
            </tr>
            <tr v-for="entry in tasks" :key="entry.id" v-if="apply_filter(entry)">
                <td><pre>[[toLocalTime(entry.timestamp)]]</pre></td>
                <td>
                    <template v-if="entry.opsec_pre_blocked === true && entry.opsec_pre_bypassed === false">
                                 <button class="btn btn{{config['outline-buttons']}}warning btn-sm dropdown-toggle" style="border:0" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="card-text">OPSEC BLOCKED (PRE)</span></button>
                             </template>
                             <template v-else-if="entry.opsec_post_blocked === true && entry.opsec_post_bypassed === false">
                                 <button class="btn btn{{config['outline-buttons']}}warning btn-sm dropdown-toggle" style="border:0" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="card-text">OPSEC BLOCKED (POST)</span></button>
                             </template>
                            <template v-else-if="entry.status.includes('error')">
                                <button class="btn btn{{config['outline-buttons']}}danger btn-sm dropdown-toggle"  style="border:0" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="card-text">[[entry.status]]</span></button>
                            </template>
                            <template v-else-if="entry.completed == true || entry.status === 'completed'">
                                <button class="btn btn{{config['outline-buttons']}}success btn-sm dropdown-toggle" style="border:0" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="card-text">completed</span></button>
                            </template>
                            <template v-else-if="entry.status == 'processed'">
                                <button class="btn btn{{config['outline-buttons']}}primary btn-sm dropdown-toggle"  style="border:0" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="card-text">[[entry.status]]</span></button>
                            </template>
                            <template v-else-if="entry.status == 'processing' || entry.status == 'cleared'">
                                <button class="btn btn{{config['outline-buttons']}}warning btn-sm dropdown-toggle"  style="border:0" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="card-text">[[entry.status]]</span></button>
                            </template>

                            <template v-else>
                                <button class="btn btn{{config['outline-buttons']}}info btn-sm dropdown-toggle"  style="border:0" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="card-text">[[entry.status]]</span></button>
                            </template>
                </td>
                <td><pre>[[entry.operator]]</pre></td>
                <td>[[entry.host]]<br/>
                    <pre><template v-if="entry.domain !== ''">[[entry.domain]]\</template>[[entry.user]]<template v-if="entry.integrity_level > 2">*</template> (<a :href="'{{http}}://{{links.server_ip}}:{{links.server_port}}/split_callbacks/' + entry.callback" target="_blank">[[entry.callback]]</a>)</pre></td>
                <td><a :href="entry.href" target="_blank">[[entry.id]]</a></td>
                <td><b>[[entry.command]]</b>&nbsp;
                    <template v-if="entry.original_params.length > 500">
                        [[entry.original_params.substring(0, 500)]].....
                    </template>
                    <template v-else>
                        [[entry.original_params]]
                    </template>
                </td>
                <td>[[entry.comment]]</td>
            </tr>
        </table>
    </div>
</div>

{% endblock %}

{% block scripts %}
{% include "live_feed.js" %}
{% endblock %}

{% block body_config %}
.btn.disabled, .btn:disabled {
    opacity: 1 !important;
}
{% endblock %}